﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CMISLibrary;
using System.Data.OracleClient;
using System.Windows;
using System.Windows.Forms;
using ObjectDanhMuc.DB;
using ObjectDanhMuc;
using CMISLibrary.Libraries;

namespace busDanhMuc
{
    public class cls_NPC_USER_bus
    {
        #region   Atributes

        private cls_NPC_USER_Controller obj_NPC_USER_Controller;

        # endregion
        #region   Constructor

        public cls_NPC_USER_bus()
        {
            obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
        }
        #endregion
        # region Mapinfo
        public void mapEntityToInfo(DataSet Entity)
        {
            if (this.obj_NPC_USER_Controller == null)
            {
                this.obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
            }

            if (Entity.Tables["NPC_USER"].Rows[0]["USERID"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.USERID = Convert.ToInt64(Entity.Tables["NPC_USER"].Rows[0]["USERID"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["MA_DVIQLY"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.MA_DVIQLY = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["MA_DVIQLY"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["USERNAME"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.USERNAME = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["USERNAME"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["PASSWORD"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.PASSWORD = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["PASSWORD"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["FULLNAME"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.FULLNAME = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["FULLNAME"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["EMAIL"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.EMAIL = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["EMAIL"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["PHONE"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.PHONE = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["PHONE"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["MOBILE"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.MOBILE = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["MOBILE"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["DEPT"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.DEPT = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["DEPT"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["STATE"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.STATE = Convert.ToInt16(Entity.Tables["NPC_USER"].Rows[0]["STATE"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["TYPEOFUSER"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.TYPEOFUSER = Convert.ToInt16(Entity.Tables["NPC_USER"].Rows[0]["TYPEOFUSER"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["CREATEDDATE"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.CREATEDDATE = Convert.ToDateTime(Entity.Tables["NPC_USER"].Rows[0]["CREATEDDATE"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["ISUSED"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.ISUSED = Convert.ToInt16(Entity.Tables["NPC_USER"].Rows[0]["ISUSED"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["EXPIREDTIME"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.EXPIREDTIME = Convert.ToDateTime(Entity.Tables["NPC_USER"].Rows[0]["EXPIREDTIME"].ToString());
            }
            if (Entity.Tables["NPC_USER"].Rows[0]["CREATEDBY"].ToString().Trim() != string.Empty)
            {
                this.obj_NPC_USER_Controller.pInfor.CREATEDBY = Convert.ToString(Entity.Tables["NPC_USER"].Rows[0]["CREATEDBY"].ToString());
            }
        }

        #endregion mapinfo
        #region NPC_USER_OMS
        public DataSet GET_DVIQLY_QUANTRI()
        {
            DataSet ds = new DataSet();
            try
            {
                ds = obj_NPC_USER_Controller.GET_DVIQLY_QUANTRI();
                return ds;
            }
            catch
            { return null; }
        }
        public DataSet GET_USER_QUANTRI(string USER_NAME, string PASS, string SMA_DVIQLY, ref string maloi)
        {
            DataSet ds = new DataSet();
            try
            {
                ds = obj_NPC_USER_Controller.GET_USER_QUANTRI(USER_NAME, PASS, SMA_DVIQLY, ref  maloi);
                return ds;
            }
            catch
            { return null; }
        }
        public DataSet GET_USERNAME(string SMA_DVIQLY, ref string maloi)
        {
            DataSet ds = new DataSet();
            try
            {
                ds = obj_NPC_USER_Controller.GET_USERNAME(SMA_DVIQLY, ref  maloi);
                return ds;
            }
            catch
            { return null; }
        }
        public DataSet GET_USERNAME_NGUOIDUNG(string SMA_DVIQLY, string User, ref string maloi)
        {
            DataSet ds = new DataSet();
            try
            {
                ds = obj_NPC_USER_Controller.GET_USERNAME_NGUOIDUNG(SMA_DVIQLY, User, ref  maloi);
                return ds;
            }
            catch
            { return null; }
        }
        public bool Check_USERNAME(string USER_NAME, string SMA_DVIQLY)
        {
            if (obj_NPC_USER_Controller == null)
            {
                obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
            }
            return this.obj_NPC_USER_Controller.Check_USERNAME(USER_NAME, SMA_DVIQLY);
        }
        public bool insert_USERNAME(DataSet Entity, ref string maloi)
        {
            this.mapEntityToInfo(Entity);
            if (obj_NPC_USER_Controller == null)
            {
                obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
            }
            return this.obj_NPC_USER_Controller.insert_NPC_USER(ref maloi);
        }
        public bool delete_USERNAME(string s_dviqly, string username, ref string maloi)
        {
            if (obj_NPC_USER_Controller == null)
            {
                obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
            }
            return this.obj_NPC_USER_Controller.delete_NPC_USER(s_dviqly, username, ref maloi);
        }
        public bool update_USERNAME(string s_dviqly, string username, string fullname, string pass, string email, string phone, short trangthai, ref string maloi)
        {
            if (obj_NPC_USER_Controller == null)
            {
                obj_NPC_USER_Controller = new cls_NPC_USER_Controller();
            }
            return this.obj_NPC_USER_Controller.update_NPC_USER(s_dviqly, username, fullname, pass, email, phone, trangthai, ref maloi);
        }
        #endregion
    }
}
